package com.atguigu.controller;

import com.atguigu.entity.Dict;
import com.atguigu.result.Result;
import com.atguigu.service.DictService;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Controller
@RequestMapping("/dict")
public class DictControlller {
    @DubboReference
    private DictService dictService;


    @RequestMapping("/findListByParentId/{parentId}")
    @ResponseBody
    public Result<List<Dict>> findListByParentId(@PathVariable(name = "parentId") Long parentId){
        List<Dict> dictList = dictService.findListByParentId(parentId);
        Result<List<Dict>> result = Result.ok(dictList);
        return result;
    }

    @RequestMapping("/findListByDictCode/{dictCode}")
    @ResponseBody
    public Result<List<Dict>> findListByDictCode(@PathVariable(name = "dictCode") String dictCode){
        List<Dict> dictList = dictService.findListByDictCode(dictCode);
        Result<List<Dict>> result = Result.ok(dictList);
        return result;
    }
}
